package com.ym.manager.admin.user.model;

import com.ym.manager.admin.user.AccountFlowType;
import com.ym.utils.StringHandler;

/**
 * @Author 但何非
 * @Date 2022/11/16 14:31
 * @ClassName: AccountFlow
 * @Description:
 * @Version:
 */
public class AccountFlow {
    public long id;
    public String type;
    public String amount;
    public String balance_before;
    public String balance_after;
    public String freeze_amount_before;
    public String freeze_amount_after;
    public String flag;
    public int payChannel;
    public String remark;
    public String raw_add_time;

    public AccountFlowVo toVo(){
        AccountFlowVo accountFlowVo = new AccountFlowVo();
        accountFlowVo.id = this.id;
        accountFlowVo.type = AccountFlowType.getNameByCode(this.type);
        accountFlowVo.amount = this.amount;
        accountFlowVo.balance_before = this.balance_before;
        accountFlowVo.balance_after = this.balance_after;
        accountFlowVo.freeze_amount_before = this.freeze_amount_before;
        accountFlowVo.freeze_amount_after = this.freeze_amount_after;
        if("1".equals(this.flag)){
            accountFlowVo.flag = "收入";
        }
        if("2".equals(this.flag)){
            accountFlowVo.flag = "支出";
        }
        if("".equals(this.flag)){
            accountFlowVo.flag = "修改冻结金额";
        }
        accountFlowVo.payChannel = this.payChannel();
        accountFlowVo.remark = this.remark;
        if(!StringHandler.isEmpty(this.raw_add_time)){
            if(this.raw_add_time.length()>19){
                accountFlowVo.raw_add_time = this.raw_add_time.substring(0,19);
            }else{
                accountFlowVo.raw_add_time = this.raw_add_time;
            }
        }
        return accountFlowVo;
    }
    public String payChannel(){
        switch (this.payChannel){
            case 1 :
                return "墨宝";
            case 2 :
                return "银盛";
            case 3 :
                return "支付宝";
            case 5 :
                return "汇聚支付";
            default:
                return "";
        }
    }
}
